package com.zy.test.threaddemo;

import java.lang.reflect.Array;
import java.util.*;

/**
 * @author MissZhou
 * 第一种方式：通过继承Thread类，重写run()方法创建，底层实现Runnable类。
 */
public class CreateByThread extends Thread{

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(i);
        }
    }

    public static void main(String[] args) {
        //new CreateByThread().start();
        String str = "Hello,world";
//        Map<Character, Integer> map = new HashMap<>();
//        for (int i = 0; i < str.length(); i++) {
//            char charAt = str.charAt(i);
//            map.put(charAt,map.getOrDefault(charAt,0)+1);
//        }
//        System.out.println(map);
//        List<String> strings = Arrays.asList(str.split(""));
//        StringBuffer sb = new StringBuffer();
//        strings.stream().forEach(s -> sb.append(s).append("_"));
//        System.out.println(sb.substring(0,sb.length()-1));
//        for (int i = 0; i < strings.size(); i++) {
//            sb.append(str.charAt(i));
//            sb.append("_");
//        }
        String[] split = str.split("");
        StringJoiner stringJoiner = new StringJoiner("_");
        Arrays.stream(split).forEach(a->stringJoiner.add(a));
        System.out.println(stringJoiner);
    }




}
